<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script th:src="@{/js/ions_alert.js}"></script>
    <script th:src="@{/common/common.js}"></script>
    <script th:src="@{/js/sweetalert.min.js}"></script>
    <link rel="stylesheet" th:href="@{/css/sweetalert.css}">
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">首页</a>
        <a href="#">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <dd class="layui-form layui-col-md12 x-so">
            <div class="layui-input-inline">
                <select name="pageSize" id="time">
                    <option value="1">一个月内</option>
                    <option value="2">两个月内</option>
                    <option value="3">三个月内</option>
                    <option value="6">半年内</option>
                    <option value="12">一年内</option>
                </select>
            </div>
            <button class="layui-btn" lay-submit="" lay-filter="search" id="search"><i class="layui-icon" >&#xe615;</i></button>
        </dd>
    </div>
    <table class="layui-table middle">
        <thead>
        <tr>
            <th>月份</th>
            <th>售货员名</th>
            <th>售货次数</th>
            <th>售货金额</th>
            <th>基本工资</th>
            <th>奖励工资</th>
            <th>实际工资</th>
        </tr>
        </thead>
        <tbody id="tbody" class="salaryList">
        </tbody>
    </table>

</div>
<script>
    $(function () {

        $("#search").click(function () {
            //获取时间
            let time = $("#time option:selected").val();
            findSalary(time);
        })
    });
    //查找 工资 通过时间
    function findSalary(time) {
        $.ajax({
            url: "/sales/findSalary",
            type: "PUT",
            data:　{
                time:time
            },
            success:function (resultInfo) {
                if(resultInfo.flag){
                    var text = '';
                    for (let i = 0; i < resultInfo.data.length; i++) {
                        text += '<tr>\n' +
                            '                <td>'+resultInfo.data[i].timeMonth+'</td>\n'+
                            '                <td>'+resultInfo.data[i].username+'</td>\n' +
                            '                <td>'+resultInfo.data[i].many+'</td>\n' +
                            '                <td>'+resultInfo.data[i].price+'</td>\n' +
                            '                <td>'+resultInfo.data[i].base+'</td>\n' +
                            '                <td>'+resultInfo.data[i].reward+'</td>\n' +
                            '                <td>'+resultInfo.data[i].trueReward+'</td>\n' +
                            '            </tr>';
                    }
                    text += '';
                    $(".salaryList").html(text);
                }else {
                    alert(resultInfo.message);
                }
            }
        })
    }
</script>
</body>
</html>